<template>
  <div>
    用户修改功能
    <form>
      姓名：<input type="text" v-model="user.name"/><br/>
      年龄：<input type="text" v-model="user.age"/><br/>
      工资：<input type="text" v-model="user.salary"/><br/>
      电话号码：<input type="text " v-model="user.phone"/><br/>
      <input type="button" value="修改" @click="EditUser"/>

    </form>
  </div>
</template>

<script>
    export default {
      name: "UserEdit",
      data(){
        return{
          user:{}
        }
      },
      methods:{
        EditUser(){
          this.$http.post("http://localhost:8989/user/insertUser",this.user).then((res)=>{
            if(res.data.status == true){
              this.$router.push('/User');
              alert("修改成功！");
            }
          })
        }
      },
      created(){
        console.log("this.$route.query.id:"+this.$route.query.id);
        this.$http.get("http://localhost:8989/user/findOne?id="+this.$route.query.id).then((res)=>{
          this.user = res.data;
        })
      }
    }
</script>

<style scoped>

</style>
